package com.dk.date;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.time.*;

public class DateTest {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        LocalDateTime of = LocalDateTime.of(2021, 12, 12, 12, 12);
        System.out.println(of);
        //从当前时间往前推8天
        LocalDateTime localDateTime = now.minusDays(8);
        System.out.println(localDateTime);
        //减完之后是周几
        DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
        System.out.println(dayOfWeek);
        //转成周几转成数字
        int value = dayOfWeek.getValue();
        System.out.println(value);
        //获取月份
        Month month = localDateTime.getMonth();
        System.out.println(month);
        System.out.println(month.getValue());
        //获取日期是当前月的第几天
        int dayOfMonth = localDateTime.getDayOfMonth();
        System.out.println(dayOfMonth);
        //获取日期是这一年的第几天
        int dayOfYear = localDateTime.getDayOfYear();
        System.out.println(dayOfYear);
        //获取日期是哪一年
        int year = localDateTime.getYear();
        System.out.println(year);
        System.out.println(localDateTime.getHour());//获取小时
        System.out.println(localDateTime.getMinute());//获取分钟

        //加发
        now.plusDays(8);//加8天
        now.plusMonths(1);//加一个月
        now.minusMonths(1);//减一个月

        LocalDate.now();//只获取年月日
        LocalTime.now();//只获取时分秒

        now.getNano();//获取纳秒,没有获取毫秒的功能

        //获取毫秒值
        Instant now1 = Instant.now();
        long l = now1.toEpochMilli();
        System.out.println(l);
    }
}
